﻿// 标准C++头文件
#include <iostream>
#include <string>
// Linux头文件
#include <sys/stat.h>
// 三方库头文件
#include "glog/logging.h"
// 用户头文件
#include "networkcaptor.h"
#include "capture/interface.h"
#include "public/packet.h"

using namespace std;

NetworkCaptor::NetworkCaptor(list<string> ifNameList)
{
    // 初始化接口名
    if(ifNameList.size() == 0){
        auto inter = Interface::GetAllInterface();
        for(auto it : inter){
            ifNameList.push_back(it.first);
        }
    }
    // 创建接口
    for(auto it : ifNameList){
        this->interface.push_back(Interface(it));
    }

    // 打印接口信息
    for(auto it : this->interface){
        cout << it.info.name << " - ";
        cout << it.info.address.ip << endl;
    }
}